/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.persistence.account;

import deti.es.ukni.persistence.entity.Account;
import deti.es.ukni.persistence.entity.Band;
import java.util.Date;
import java.util.List;
import javax.ejb.Remote;

/**
 * AccountManager remote interface.
 *
 *
 * @author ukni
 */
@Remote
public interface AccountManagerRemote {

    /**
     * Create a new account
     *
     * @param username
     * @param email
     * @param password
     * @param accountType
     * @return  The account created, or null if something goes wrong.
     */
    public Account createAccount(String username, String email,
                                 String password, Integer accountType);

    /**
     * Create a new Band.
     *<br/>
     * Each band is associated to only -- i repeat, only -- one Account
     *
     * @param owner the manager of the band
     * @param name the name of the band
     * @param dateFormation band formation date
     * @param description text containing the band description
     * @param biography text containing the band biography.
     * @return the Band created, or null if something goes wrong.
     */
    public Band createBand(Account owner, String name,Date dateFormation,
                           String description, String biography );

    /**
     * Update an existing Account
     *
     * @param account to update.
     */
    public void updateAccount(Account account );

    /**
     * Update an existing Band
     *
     * @param band to update
     */
    public void updateBand(Band band);

    /**
     * Send an email with a new password
     *
     * @param email Recipient email.
     */
    public void requestNewPassword( String email );

    /**
     * Find all accounts in the database
     *
     * @return a list with all accounts.
     */
    public List<Account> findAllAccounts();

    /**
     * Check user password against the password
     * stored in the database.
     *
     * @param Username  The name of the user
     * @param passwd    The password to check
     *
     * @return An Account object if the password checks, null otherwise.
     *
     * @throws AccountDoesNotExist when the username does not exist.
     * @throws WrongPassword when the passords does not checks.
     */
    public Account login( String Username, String passwd) 
                        throws AccountDoesNotExist, WrongPassword ;

    /**
     * Search for an account that matches the given id.
     *
     * @param IDAccount The id of the account.
     * @return An Account object that matches <code>IDAccount</code>,
     *         null otherwise.
     */
    public Account findAccount(Integer IDAccount);

    /**
     * Find a specific account by its name.
     *
     * @param name  The name of the account to search for.
     * @return      An Account object.
     * @throws AccountDoesNotExist when the with username <code>name</name>
     * does not exist.
     */
    public Account findAccount(String name) throws AccountDoesNotExist;
    public List<Band> findBands(String name) throws AccountDoesNotExist;
    public Band findBand(Integer IDBand) throws AccountDoesNotExist;

    public void refreshAccount(Account account);
}
